//
//  HaveLogRechargeTableViewCell.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/10.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "HaveLogRechargeTableViewCell.h"

@interface HaveLogRechargeTableViewCell()
@property (nonatomic, strong)UIView * whiteBGView;
@property (nonatomic, strong)UIButton * circleBtn;
@property (nonatomic, strong)UILabel * nameLab;
@property (nonatomic, strong)UILabel * projectLab;
@property (nonatomic, strong)UILabel * moneyLab;
@property (nonatomic, strong)UILabel * timeLab;
@end

@implementation HaveLogRechargeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = getColor(@"f5f5f5");
        __weak typeof (self)weakSelf = self;
        [self.contentView addSubview:self.whiteBGView];
        [self.contentView addSubview:self.circleBtn];
        [self.contentView addSubview:self.nameLab];
        [self.contentView addSubview:self.projectLab];
        [self.contentView addSubview:self.moneyLab];
        [self.contentView addSubview:self.timeLab];
        [self.whiteBGView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(15/WIDTH_6_SCALE);
        }];
        [self.circleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(13/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.whiteBGView.mas_centerY);
            make.height.width.mas_offset(22/WIDTH_6_SCALE);
        }];
        [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.circleBtn.mas_right).mas_offset(18/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.whiteBGView.mas_top).mas_offset(34/WIDTH_6_SCALE);
            make.height.mas_offset(18/WIDTH_6_SCALE);
        }];
        [self.projectLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.nameLab.mas_bottom).mas_offset(12/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.nameLab);
            make.height.mas_offset(13/WIDTH_6_SCALE);
        }];
        [self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.whiteBGView.mas_right).mas_offset(-122/WIDTH_6_SCALE);
            make.height.centerY.equalTo(weakSelf.nameLab);
            make.right.equalTo(weakSelf.whiteBGView.mas_right).mas_offset(-13/WIDTH_6_SCALE);
        }];
        [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.moneyLab.mas_left);
            make.top.height.equalTo(weakSelf.projectLab);
        }];
    }return self;
}
- (UIView *)whiteBGView{
    if (!_whiteBGView) {
        _whiteBGView = [[UIView alloc] init];
        _whiteBGView.backgroundColor = [UIColor whiteColor];
    }return _whiteBGView;
}
- (UIButton *)circleBtn{
    if (!_circleBtn) {
        _circleBtn = [[UIButton alloc] init];
        [_circleBtn setImage:[UIImage imageNamed:@"unselected_index_icon"] forState:UIControlStateNormal];
        [_circleBtn setImage:[UIImage imageNamed:@"selected_index_icon"] forState:UIControlStateSelected];
        [_circleBtn addTarget:self action:@selector(circleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//        [_circleBtn setBackgroundColor:[UIColor redColor]];
//        _stateBtn.layer.cornerRadius = 6;
//        _stateBtn.layer.masksToBounds = YES;
    }return _circleBtn;
}

- (UILabel *)nameLab{
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] init];
        _nameLab.font = DEF_FontSize_14;
        _nameLab.textColor = [UIColor blackColor];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.text = @"王宝强";
    }return _nameLab;
}
- (UILabel *)projectLab{
    if (!_projectLab) {
        _projectLab = [[UILabel alloc] init];
        _projectLab.font = DEF_FontSize_12;
        _projectLab.textColor = getColor(@"a5a5a5");
        _projectLab.textAlignment = NSTextAlignmentLeft;
        _projectLab.text = @"综合意外互助计划";
    }return _projectLab;
}
- (UILabel *)moneyLab{
    if (!_moneyLab) {
        _moneyLab = [[UILabel alloc] init];
        _moneyLab.font = DEF_FontSize_14;
        _moneyLab.textColor = [UIColor blackColor];
        _moneyLab.textAlignment = NSTextAlignmentLeft;
        _moneyLab.text = @"30.00元";
    }return _moneyLab;
}
- (UILabel *)timeLab{
    if (!_timeLab) {
        _timeLab = [[UILabel alloc] init];
        _timeLab.font = DEF_FontSize_12;
        _timeLab.textColor = getColor(@"a5a5a5");
        _timeLab.textAlignment = NSTextAlignmentLeft;
        _timeLab.text = @"余额可用约13个月";
    }return _timeLab;
}
- (void)circleBtnClick:(UIButton *)sender{
    sender.selected = !sender.selected;
}
- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.nameLab.text = model[@"realname"];
    self.moneyLab.text = [NSString stringWithFormat:@"%@元", model[@"pay_num"]];
//    self.timeLab.text = model[@""];
    self.projectLab.text = model[@"helpname"];
}
@end
